package net.ziqiang.sdk.teagreen.util;

import java.util.*;
import java.text.SimpleDateFormat;

public class DateTime {
	/**
	 * Get a date string formated as yyyy-MM-dd.
	 * @return 
	 */
	public String getDate(){
		Calendar cal=Calendar.getInstance();
		SimpleDateFormat sdf= new SimpleDateFormat();
		sdf.applyPattern("yyyy-MM-dd");
		String date=sdf.format(cal.getTime());
		return date;
	}

	/**
	 * Get a date string formated as given pattern.
	 * @param patten string
	 * @return 
	 */
	public String getDate(String patten){
		Calendar cal=Calendar.getInstance();
		SimpleDateFormat sdf= new SimpleDateFormat();
		sdf.applyPattern(patten);
		String date=sdf.format(cal.getTime());
		return date;
	}
	
	/**
	 * Get a timestamp
	 * @return
	 */
	public String getTimestamp(){
		return getDate("yyyy-MM-dd HH:mm:ss");
	}
}
